import { createWebHashHistory, createRouter } from "vue-router";
import { h } from "vue";
import { NIcon } from "naive-ui";
import MainPage from "@/Main.vue";
import LoginPage from "@/views/system/login.vue";
import {
  Home24Regular as indexIcon,
  Briefcase24Regular as majorIcon,
  People24Regular as userIcon,
  DataArea24Regular as dataPanelIcon,
  ClipboardTaskListLtr24Regular as recordIcon,
  DataTreemap24Regular as positionIcon,
} from "@vicons/fluent";
const renderIcon = (icon) => {
  return () => h(NIcon, null, { default: () => h(icon) });
};

const routes = [
  { path: "/", redirect: "/home/index" },
  { path: "/home", redirect: "/home/index" },
  {
    path: "/home",
    component: MainPage,
    name: "main",
    children: [
      {
        path: "index",
        name: "index",
        meta: {
          label: "首页",
          key: "index",
          icon: renderIcon(indexIcon),
        },
        component: () => import("@/views/index.vue"),
      },
      {
        path: "dataPanel",
        name: "dataPanel",
        meta: {
          label: "数据面板",
          key: "dataPanel",
          icon: renderIcon(dataPanelIcon),
        },
        component: () => import("@/views/dataPanel/dataPanel.vue"),
      },
      {
        path: "user",
        name: "user",
        meta: {
          label: "用户设置",
          key: "user",
          icon: renderIcon(userIcon),
        },
        component: () => import("@/views/user/user.vue"),
      },
      {
        path: "major",
        name: "major",
        meta: {
          label: "专业设置",
          key: "major",
          icon: renderIcon(majorIcon),
        },
        component: () => import("@/views/major/major.vue"),
      },
      {
        path: "position",
        name: "position",
        meta: {
          label: "点位设置",
          key: "position",
          icon: renderIcon(positionIcon),
        },
        component: () => import("@/views/position/position.vue"),
      },
      {
        path: "record",
        name: "record",
        meta: {
          label: "巡检记录",
          key: "record",
          icon: renderIcon(recordIcon),
        },
        component: () => import("@/views/record/record.vue"),
      },
    ],
  },
  {
    path: "/login",
    name: "/login",
    component: LoginPage,
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
